package com.jaxb2;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
class Employee{
	private int id;
	private String name;
	private String address;
	private long phone;
	public Employee() {
	}
	public Employee(int id,String name,String address,long phone){
		this.id=id;
		this.name=name;
		this.address=address;
		this.phone=phone;
	}
	public int getId() {
		return id;
	}
	@XmlElement
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	@XmlElement
	public void setName(String name) {
		this.name = name;
	}
	public String getAddress() {
		return address;
	}
	@XmlAttribute
	public void setAddress(String address) {
		this.address = address;
	}
	public long getPhone() {
		return phone;
	}
	@XmlAttribute
	public void setPhone(long phone) {
		this.phone = phone;
	}
	@Override
	public String toString() {
		return id+"\t"+name+"\t"+address+"\t"+phone;
	}
	
}
class ListOfEmployee{
private List<Employee> employee;
public List<Employee> getEmployee() {
	return employee;
}
public void setEmployee(List<Employee> employee) {
	this.employee = employee;
}
}
public class MarsallingExample1 {
public static void main(String[] args)throws Exception{

	Employee employee=new Employee(1, "deepak", "pakur", 90909);
	
	File file=new File("C:\\file\\employee.txt");
	JAXBContext jaxbContext=JAXBContext.newInstance(Employee.class);
	Marshaller marshaller=jaxbContext.createMarshaller();
	marshaller.marshal(employee, file);
	marshaller.marshal(employee, System.out);
	
}
}
